Skip to content

feat: expose individual ResourceConstraints setters and getters#1918

Merged
bartlomieju merged 7 commits intomainfrom
feat/resource-constraints-api
Mar 4, 2026
Merged

feat: expose individual ResourceConstraints setters and getters#1918
bartlomieju merged 7 commits intomainfrom
feat/resource-constraints-api

Conversation

@bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Mar 3, 2026

Summary

  • Add C++ bindings and Rust wrappers for the individual v8::ResourceConstraints setter/getter methods
  • Expose them as builder-style methods on CreateParams (e.g., set_max_old_generation_size_in_bytes)
  • Previously only ConfigureDefaultsFromHeapSize and ConfigureDefaults were exposed, which don't allow setting individual generation limits

Motivation

Deno needs these to properly implement Node.js-compatible worker_threads resource limits (maxOldGenerationSizeMb, maxYoungGenerationSizeMb, codeRangeSizeMb, stackSizeMb). Node.js uses these individual setters in node_worker.cc via Worker::UpdateResourceConstraints.

Add bindings for the V8 ResourceConstraints API so that embedders can
set individual heap generation limits instead of only using the
high-level ConfigureDefaultsFromHeapSize helper.

New APIs on CreateParams:
- set_max_old_generation_size_in_bytes / max_old_generation_size_in_bytes
- set_max_young_generation_size_in_bytes / max_young_generation_size_in_bytes
- set_code_range_size_in_bytes / code_range_size_in_bytes
- set_stack_limit / stack_limit
- set_initial_old_generation_size_in_bytes / initial_old_generation_size_in_bytes
- set_initial_young_generation_size_in_bytes / initial_young_generation_size_in_bytes

This is needed by Deno to properly implement Node.js-compatible worker
thread resource limits (maxOldGenerationSizeMb, maxYoungGenerationSizeMb,
codeRangeSizeMb, stackSizeMb).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bartlomieju bartlomieju enabled auto-merge (squash) March 4, 2026 07:25
@bartlomieju bartlomieju merged commit 50067f0 into main Mar 4, 2026
38 of 39 checks passed
@bartlomieju bartlomieju deleted the feat/resource-constraints-api branch March 4, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants